<?php
class Department extends AppModel {
	var $name = 'Department';
	var $primaryKey = 'id';
	
	var $validate = array(
		'name' => 'notEmpty'
	);
	
	var $hasMany = array(
		'Project' => array(
			'className' => 'Project',
			'foreignKey' => 'department_id'
		)
	);
	
	//zistuje, ci je katedra pripojena k nejakemu projektu
	public function isAssociated($id) {
		return (bool) $this->Project->find('count', array('conditions' => array(
			'Project.department_id' => $id
		)));
	}
	
}
?>